"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createImport = void 0;
const path_1 = __importDefault(require("path"));
const fs_extra_1 = __importDefault(require("fs-extra"));
const form_data_1 = __importDefault(require("form-data"));
const http_1 = require("../http");
const path_2 = require("../lib/path");
const HUBSPOT_CRM_IMPORT_PATH = '/crm/v3/imports';
function createImport(accountId, importRequest, dataFileNames) {
    const jsonImportRequest = JSON.stringify(importRequest);
    const formData = new form_data_1.default();
    formData.append('importRequest', jsonImportRequest);
    dataFileNames.forEach(file => {
        const stream = fs_extra_1.default.createReadStream(path_1.default.resolve((0, path_2.getCwd)(), file));
        formData.append('files', stream, file);
    });
    return http_1.http.post(accountId, {
        url: `${HUBSPOT_CRM_IMPORT_PATH}`,
        data: formData,
        headers: {
            ...formData.getHeaders(),
        },
    });
}
exports.createImport = createImport;
